<template>
    <el-scrollbar wrap-class="scrollbar-wrapper">
        <el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse" background-color="#304156" text-color="#fff" active-text-color="#409EFF">
            <div class="h3" v-show="!isCollapse">泥页岩岩相识别系统</div>
            <h3 class="h3" v-show="isCollapse">后台</h3>
            <!-- <el-submenu index="1">
          <template slot="title">
            <i style="color: #fff;" class="el-icon-setting"></i>
            <span>系统设置</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="1-1" @click="handleSys()">全局设置</el-menu-item>
          </el-menu-item-group>
          <el-submenu index="1-2">
            <template slot="title">组织架构</template>
            <el-menu-item index="1-2-1">组织类型管理</el-menu-item>
            <el-menu-item index="1-2-2">组织机构管理</el-menu-item>
            <el-menu-item index="1-2-3">角色管理</el-menu-item>
            <el-menu-item index="1-2-4">用户管理</el-menu-item>
          </el-submenu>
            <el-menu-item index="1-3">基础设置</el-menu-item>
          </el-menu-item-group>
          <el-submenu index="1-4">
            <template slot="title">资源管理</template>
            <el-menu-item index="1-4-1">页面按钮管理</el-menu-item>
            <el-menu-item index="1-4-2">菜单管理</el-menu-item>
          </el-submenu>
          <el-submenu index="1-5">
            <template slot="title">权限设置</template>
            <el-menu-item index="1-4-1">角色菜单授权</el-menu-item>
            <el-menu-item index="1-4-2">用户菜单授权</el-menu-item>
            <el-menu-item index="1-4-3">角色组织授权</el-menu-item>
            <el-menu-item index="1-4-4">用户组织授权</el-menu-item>
            <el-menu-item index="1-4-5">角色下属用户</el-menu-item>
          </el-submenu>
        </el-submenu> -->
            <el-menu-item :index="item.path" v-for="item  in noChildren" :key="item.path" @click="clickMen(item)">
                <i :class="'el-icon-'+item.icon"></i>
                <span slot="title">{{item.label}}</span>
            </el-menu-item>
            <el-submenu :index="v.path" v-for="v in hasChildren" :key="v.path">
                <template slot="title">
                    <i :class="'el-icon-'+v.icon"></i>
                    <span>{{v.label}}</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item :index="sub.path" v-for="sub in v.children" :key="sub.path" @click="clickMen(sub)">
                        <i :class="'el-icon-'+sub.icon"></i>
                        <span>{{sub.label}}</span>
                    </el-menu-item>
                </el-menu-item-group>
            </el-submenu>
            <!-- <el-submenu index="1">
          <template slot="title">
            <i style="color: #fff;" class="el-icon-coin"></i>
            <span>数据管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="1-1" @click="handleSys()">元数据</el-menu-item>
            <el-menu-item index="1-2">历史记录</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="2">
          <template slot="title">
            <i style="color: #fff;" class="el-icon-document-checked"></i>
            <span>模型管理</span>
          </template>
        </el-submenu>
        <el-submenu index="3">
          <template slot="title">
            <i style="color: #fff;" class="el-icon-user"></i>
            <span>用户管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="3-1">用户信息</el-menu-item>
          </el-menu-item-group>
        </el-submenu> -->
        </el-menu>
    </el-scrollbar>
</template>

<script>
    import { navList } from '../../router/routes.js'
    export default {
        data() {
            return {

            };
        },
        methods: {
            handleOpen(key, keyPath) {
                console.log(key, keyPath);
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },
            handleSys() {
                this.$router.push('/index')
            },
            handeOrg() {
                this.$router.push('/orgStruct')
            },
            handleClose(key, keyPath) {
                console.log(key, keyPath);
            },
            clickMen(item) {
                console.log(item, 'item')
                this.$router.push({ path: item.path })
            }

        },
        mounted() {

        },
        computed: {

            noChildren() {
                console.log(navList, '22222222')
                return navList.filter((item) => !item.children)
            },
            hasChildren() {
                return navList.filter((item) => item.children)
            },
            isCollapse() {
                return this.$store.state.tab.isCollapse
            }
        }
    }
</script>

<style>
    .el-menu-vertical-demo:not(.el-menu--collapse) {
        min-height: 400px;
    }

    .el-scrollbar {
        height: 100%;
    }

    .el-scrollbar__wrap {
        overflow-x: hidden;
        overflow-y: scroll;
    }

    .h3 {
        color: #fff;
        text-align: center;
        font-size: 18px;
        margin-top: 10px;
        font-weight: 600;
        margin-left: 5px;
        margin-right: 5px;
    }
</style>